﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.ConvertClass;
using 纸片人.win2dEffectControl.DataClass;

using 纸片人.CalculateControls;
// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public sealed class ScaleEffectControl : EffectControl
    {

        private ComboBox interpolationModeComboBox;
        private ComboBox borderModeModeComboBox;
        private Vector2Control centerPointVector2Control;
        private Vector2Control scaleVector2Control;
        private TextBoxSlider sharpnessTexBoxSlider;
        public override EffectOneSourceData OneEffetData { get; set; }
        List<CanvasImageInterpolation> listCanvasImageInterpolation = new List<CanvasImageInterpolation>();
        List<EffectBorderMode> listborderMode = new List<EffectBorderMode>();
        public ScaleEffectControl()
        {
            this.DefaultStyleKey = typeof(ScaleEffectControl);
            listCanvasImageInterpolation=EffectUtil.GetEnumList<CanvasImageInterpolation>();    
                listborderMode = EffectUtil.GetEnumList<EffectBorderMode>();
            OneEffetData = new ScaleEffectData();
        }

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            SetEffectName("缩放效果", "ChromaKeyEffect");


            interpolationModeComboBox = GetTemplateChildFormName<ComboBox>(nameof(interpolationModeComboBox));
            SetComboBox(interpolationModeComboBox, listCanvasImageInterpolation, OneEffetData, nameof(ScaleEffectData.InterpolationMode));

            borderModeModeComboBox = GetTemplateChildFormName<ComboBox>(nameof(borderModeModeComboBox));
            SetComboBox(borderModeModeComboBox, listborderMode, OneEffetData, nameof(ScaleEffectData.BorderMode));


            centerPointVector2Control = GetTemplateChildFormName<Vector2Control>(nameof(centerPointVector2Control));
            SetVector2Control(centerPointVector2Control, OneEffetData, nameof(ScaleEffectData.CenterPoint));

            scaleVector2Control = GetTemplateChildFormName<Vector2Control>(nameof(scaleVector2Control));
            SetVector2Control(scaleVector2Control, OneEffetData, nameof(ScaleEffectData.Scale));


            sharpnessTexBoxSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(sharpnessTexBoxSlider));
            SetTextBoxSlider(sharpnessTexBoxSlider, OneEffetData, nameof(ScaleEffectData.Sharpness));
            
        }

    }
}

